using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Jonathan
{
	/// <summary>
	/// Class used to parse bible and other texts passages.
	/// </summary>
    public class cParser
    {
        /// <summary>
        /// Parses the given scripture reference...
        /// </summary>
        /// <param name="scripture">scripture reference.</param>
        /// <returns>List of Passages.</returns>
        public static List<cPassage> Parse (string scripture)
        {
            /*
            Gen 1 # first chapter of Genesis
            Genesis 1 # Full names supported
            1 Kgs 1 - 2 # 1st and 2nd chapter in 1 Kings
            Luke 15:8-10 # Specific verses from chapters supported
            Luke 15:1-7, 11-32 # Multiple, disjoint verse specification
            Matt 9:12; Mark 2:17; Luke 5: 31 # Multiple books together
            Gen 1, 3 # discontinuous chapters
            Gen 1 - 2:3 # Span chapters, to a specific verse
            */

            List<cPassage> PassageList = new List<cPassage>();
            
            // Check for empty string...
            if (string.IsNullOrEmpty(scripture))
                return PassageList;

            string scrip = scripture.Replace(" ", "");
            int len = scrip.Length;
            bool bBook = true;
            bool bChap = false;
            bool bVerse = false;
            string book = "";
            string chap = "";
            string verse = "";

            int a = 0;
            if (Char.IsDigit(scrip[0])) { book += scrip[0].ToString(); a++; }
            for (; a < len; a++)
            {
                char c = scrip[a];
                if (c == ':')
                {
                    bBook = false;
                    bChap = false;
                    bVerse = true;
                }
                else if (c == ',')
                {
					bool handled = false;
					if (bBook)
					{
						// We may have a comma in a book name...
						if ((a + 1) < len)
						{
							if (Char.IsLetter(scrip[a + 1]))
							{
								book += c;
								handled = true;
							}
						}
					}
					if (!handled)
					{
						AddPassage(PassageList, book, chap, verse);
						if (string.IsNullOrEmpty(verse))
						{
							chap = "";
						}
						verse = "";
					}
                }
                else if (c == ';')
                {
                    AddPassage(PassageList, book, chap, verse);
                    book = "";
                    chap = "";
                    verse = "";
                    bBook = true;
                    bChap = false;
                    bVerse = false;
                }
                else if (c == '.')
                {
					if (bBook)
					{
						bBook = false;
						bChap = true;
						bVerse = false;
					}
					else
					{
						bBook = false;
						bChap = false;
						bVerse = true;
					}
                }
                else if (c == '-')
                {
                    if (bChap)
                    {
                        chap += c;
                    }
                    else if (bVerse)
                    {
                        verse += c;
                    }
                }
                else if (Char.IsDigit(c))
                {
                    if (bBook)
                    {
                        if ((a + 1) < len && /*!*/Char.IsLetter/*.IsDigit*/(scrip[a + 1]) && string.IsNullOrEmpty(book))
                        {
                            book += c;
                        }
                        else
                        {
                            bBook = false;
                            bChap = true;
                            chap += c;
                        }
                    }
                    else if (bChap)
                    {
                        chap += c;
                    }
                    else if (bVerse)
                    {
                        verse += c;
                    }
                }
                else if(!Char.IsLetter(c))
                {
                }
                else if (bBook)
                {
                    book += c;
                }
            }
            AddPassage(PassageList, book, chap, verse);


            return PassageList;
        }

		/// <summary>
		/// Adds a passage to the passage list.
		/// </summary>
		/// <param name="passageList">List to add passage to.</param>
		/// <param name="book">Book for passage.</param>
		/// <param name="chap">Chapter for passage.</param>
		/// <param name="verse">Verse for passage.</param>
        private static void AddPassage (List<cPassage> passageList, string book, string chap, string verse)
        {
            if ((!string.IsNullOrEmpty(book) || !string.IsNullOrEmpty(verse)) && !string.IsNullOrEmpty(chap))
            {
                if (string.IsNullOrEmpty(book))
                {
                    if (passageList.Count > 0)
                    {
                        book = ((cPassage)passageList[passageList.Count - 1]).Book;
                    }
                    else
                    {
						// We don't know what book it is...
                        return;
                    }
                }

				string b = "", v = "";
                b = GetBook(book, true);
                if (string.IsNullOrEmpty(b))
                {
					if (string.IsNullOrEmpty(b)) return;
                }

                if (string.IsNullOrEmpty(verse))
                {
                    v = null;
                }
                else
                {
                    v = verse;
                }


                if (v != null && v.IndexOf("-") != -1)
                {
                    int start = Convert.ToInt32(v.Split('-')[0].Trim());
                    int end = Convert.ToInt32(v.Split('-')[1].Trim());
                    for (int a = start; a <= end; a++)
                    {
                        passageList.Add(new cPassage(b, chap, a.ToString()));
                    }
                }
                else if (chap.IndexOf("-") != -1)
                {
                    int start = Convert.ToInt32(chap.Split('-')[0].Trim());
                    int end = Convert.ToInt32(chap.Split('-')[1].Trim());
                    for (int a = start; a <= end; a++)
                    {
                        if (v != null && a == end)
                        {
                            for (int c = 1; c <= Convert.ToInt32(v); c++)
                            {
                                passageList.Add(new cPassage(b, a.ToString(), c.ToString()));
                            }
                        }
                        else
                        {
                            passageList.Add(new cPassage(b, a.ToString(), null));
                        }
                    }
                }
                else
                {
                    passageList.Add(new cPassage(b, chap, v));
                }
            }
        }

        /// <summary>
        /// Gets the name of the book for the give string...
        /// </summary>
        /// <param name="book">Book String.</param>
        /// <param name="fullName">True if you want the full name, false if you want the abbrevation.</param>
        /// <returns>Name or Abbreviation of Book</returns>
        public static string GetBook (string book, bool fullName)
        {
            string b = book.ToLower().Replace(" ", "");
            if (string.IsNullOrEmpty(b))
            {
                return null;
            }
            else if (b.Equals("genesis") || b.Equals("gen") || b.Equals("ge") || b.Equals("gn"))
            {
                return (fullName) ? "Genesis" : "Gen";
            }
            else if (b.Equals("exodus") || b.Equals("exo") || b.Equals("ex") || b.Equals("exod"))
            {
                return (fullName) ? "Exodus" : "Exo";
            }
            else if (b.Equals("leviticus") || b.Equals("lev") || b.Equals("le") || b.Equals("lv"))
            {
                return (fullName) ? "Leviticus" : "Lev";
            }
            else if (b.Equals("numbers") || b.Equals("num") || b.Equals("nu") || b.Equals("nm") || b.Equals("nb"))
            {
                return (fullName) ? "Numbers" : "Num";
            }
            else if (b.Equals("deuteronomy") || b.Equals("deut") || b.Equals("dt") || b.Equals("deu") || b.Equals("de"))
            {
                return (fullName) ? "Deuteronomy" : "Deu";
            }
            else if (b.Equals("joshua") || b.Equals("josh") || b.Equals("jos") || b.Equals("jsh"))
            {
                return (fullName) ? "Joshua" : "Jos";
            }
            else if (b.Equals("judges") || b.Equals("judg") || b.Equals("jdg") || b.Equals("jg") || b.Equals("jdgs"))
            {
                return (fullName) ? "Judges" : "Jdg";
            }
            else if (b.Equals("ruth") || b.Equals("rth") || b.Equals("ru") || b.Equals("rut"))
            {
                return "Ruth";
            }
			else if (b.Equals("1samuel") || b.Equals("1sam") || b.Equals("1sa") || b.Equals("1s") || b.Equals("1sm") || b.Equals("isam") || b.Equals("isamuel") || b.Equals("1stsamuel") || b.Equals("firstsamuel"))
            {
                return (fullName) ? "1 Samuel" : "1Sam";
            }
			else if (b.Equals("2samuel") || b.Equals("2sam") || b.Equals("2sa") || b.Equals("2s") || b.Equals("iisa") || b.Equals("2sm") || b.Equals("iisam") || b.Equals("iisamuel") || b.Equals("2ndsamuel") || b.Equals("secondsamuel"))
            {
                return (fullName) ? "2 Samuel" : "2Sam";
            }
			else if (b.Equals("1kings") || b.Equals("1kgs") || b.Equals("1kg") || b.Equals("1ki") || b.Equals("1k") || b.Equals("ikgs") || b.Equals("iki") || b.Equals("ikings") || b.Equals("1stkgs") || b.Equals("1stkings") || b.Equals("firstkings") || b.Equals("firstkgs") || b.Equals("1kin"))
            {
                return (fullName) ? "1 Kings" : "1Ki";
            }
			else if (b.Equals("2kings") || b.Equals("2kgs") || b.Equals("2kg") || b.Equals("2ki") || b.Equals("2k") || b.Equals("iikgs") || b.Equals("iiki") || b.Equals("iikings") || b.Equals("2ndkgs") || b.Equals("2ndkings") || b.Equals("secondkings") || b.Equals("secondkgs") || b.Equals("2kin"))
            {
                return (fullName) ? "2 Kings" : "2Ki";
            }
			else if (b.Equals("1chronicles") || b.Equals("1chron") || b.Equals("1ch") || b.Equals("ich") || b.Equals("1chr") || b.Equals("ichr") || b.Equals("ichron") || b.Equals("ichronicles") || b.Equals("1stchronicles") || b.Equals("firstchronicles"))
            {
                return (fullName) ? "1 Chronicles" : "1Ch";
            }
			else if (b.Equals("2chronicles") || b.Equals("2chron") || b.Equals("2ch") || b.Equals("iich") || b.Equals("iichr") || b.Equals("2chr") || b.Equals("iichron") || b.Equals("iichronicles") || b.Equals("2ndchronicles") || b.Equals("secondchronicles"))
            {
                return (fullName) ? "2 Chronicles" : "2Ch";
            }
            else if (b.Equals("ezra") || b.Equals("ezr"))
            {
                return "Ezra";
            }
            else if (b.Equals("nehemiah") || b.Equals("neh") || b.Equals("ne"))
            {
                return (fullName) ? "Nehemiah" : "Neh";
            }
            else if (b.Equals("esther") || b.Equals("esth") || b.Equals("es"))
            {
                return (fullName) ? "Esther" : "Est";
            }
            else if (b.Equals("job") || b.Equals("jb"))
            {
                return "Job";
            }
            else if (b.Equals("psalm") || b.Equals("pslm") || b.Equals("ps") || b.Equals("psalms") || b.Equals("psa") || b.Equals("psm") || b.Equals("pss"))
            {
                return (fullName) ? "Psalms" : "Ps";
            }
            else if (b.Equals("proverbs") || b.Equals("prov") || b.Equals("pr") || b.Equals("prv") || b.Equals("pro"))
            {
                return (fullName) ? "Proverbs" : "Pro";
            }
            else if (b.Equals("ecclesiastes") || b.Equals("eccles") || b.Equals("ec") || b.Equals("qoh") || b.Equals("qoheleth") || b.Equals("ecc") || b.Equals("eccl"))
            {
                return (fullName) ? "Ecclesiastes" : "Ecc";
            }
            else if (b.Equals("songofsolomon") || b.Equals("song") || b.Equals("so") || b.Equals("canticleofcanticles") || b.Equals("canticles") || b.Equals("songofsongs") || b.Equals("sos"))
            {
                return (fullName) ? "Song of Solomon" : "Sos";
            }
            else if (b.Equals("isaiah") || b.Equals("isa") || b.Equals("is"))
            {
                return (fullName) ? "Isaiah" : "Isa";
            }
            else if (b.Equals("jeremiah") || b.Equals("jer") || b.Equals("je") || b.Equals("jr"))
            {
                return (fullName) ? "Jeremiah" : "Jer";
            }
            else if (b.Equals("lamentations") || b.Equals("lam") || b.Equals("la"))
            {
                return (fullName) ? "Lamentations" : "Lam";
            }
            else if (b.Equals("ezekiel") || b.Equals("ezek") || b.Equals("eze") || b.Equals("ezk"))
            {
                return (fullName) ? "Ezekiel" : "Eze";
            }
            else if (b.Equals("daniel") || b.Equals("dan") || b.Equals("da") || b.Equals("dn"))
            {
                return (fullName) ? "Daniel" : "Dan";
            }
            else if (b.Equals("hosea") || b.Equals("hos") || b.Equals("ho"))
            {
                return (fullName) ? "Hosea" : "Hos";
            }
            else if (b.Equals("joel") || b.Equals("joe") || b.Equals("jl"))
            {
                return "Joel";
            }
            else if (b.Equals("amos") || b.Equals("am") || b.Equals("amo"))
            {
                return "Amos";
            }
            else if (b.Equals("obadiah") || b.Equals("obad") || b.Equals("ob") || b.Equals("obd") || b.Equals("oba"))
            {
                return (fullName) ? "Obadiah" : "Oba";
            }
            else if (b.Equals("jonah") || b.Equals("jnh") || b.Equals("jon"))
            {
                return (fullName) ? "Jonah" : "Jon";
            }
            else if (b.Equals("micah") || b.Equals("mic"))
            {
                return (fullName) ? "Micah" : "Mic";
            }
            else if (b.Equals("nahum") || b.Equals("nah") || b.Equals("na"))
            {
                return (fullName) ? "Nahum" : "Nah";
            }
            else if (b.Equals("habakkuk") || b.Equals("hab"))
            {
                return (fullName) ? "Habakkuk" : "Hab";
            }
            else if (b.Equals("zephaniah") || b.Equals("zeph") || b.Equals("zep") || b.Equals("zp"))
            {
                return (fullName) ? "Zephaniah" : "Zep";
            }
            else if (b.Equals("haggai") || b.Equals("hag") || b.Equals("hg"))
            {
                return (fullName) ? "Haggai" : "Hag";
            }
            else if (b.Equals("zechariah") || b.Equals("zech") || b.Equals("zec") || b.Equals("zc"))
            {
                return (fullName) ? "Zechariah" : "Zec";
            }
            else if (b.Equals("malachi") || b.Equals("mal") || b.Equals("ml"))
            {
                return (fullName) ? "Malachi" : "Mal";
            }
            else if (b.Equals("tobit") || b.Equals("tob") || b.Equals("tb"))
            {
                return "Tobit";
            }
            else if (b.Equals("judith") || b.Equals("jdth") || b.Equals("jdt") || b.Equals("jth"))
            {
                return "Judith";
            }
            else if (b.Equals("additionstoesther") || b.Equals("addesth") || b.Equals("addes") || b.Equals("restofesther") || b.Equals("therestofesther") || b.Equals("aes"))
            {
                return "Additions to Esther";
            }
            else if (b.Equals("wisdomofsolomon") || b.Equals("wisdofsol") || b.Equals("wis") || b.Equals("ws") || b.Equals("wisdom"))
            {
                return "Wisdom of Solomon";
            }
            else if (b.Equals("sirach") || b.Equals("sir") || b.Equals("ecclesiasticus") || b.Equals("ecclus"))
            {
                return "Sirach";
            }
            else if (b.Equals("baruch") || b.Equals("bar"))
            {
                return "Baruch";
            }
            else if (b.Equals("letterofjeremiah") || b.Equals("letjer") || b.Equals("lje") || b.Equals("ltrjer"))
            {
                return "Letter of Jeremiah";
            }
            else if (b.Equals("songofthreeyouths") || b.Equals("songofthree") || b.Equals("songthr") || b.Equals("thesongofthreeyouths") || b.Equals("praz") || b.Equals("prayerofazariah") || b.Equals("azariah") || b.Equals("thesongofthethreeholychildren") || b.Equals("thesongofthreejews") || b.Equals("songofthethreeholychildren") || b.Equals("songofthr") || b.Equals("songofthreechildren") || b.Equals("songofthreejews"))
            {
                return "Song of Three Youths";
            }
            else if (b.Equals("susanna") || b.Equals("sus"))
            {
                return "Susanna";
            }
            else if (b.Equals("belandthedragon") || b.Equals("bel"))
            {
                return (fullName) ? "Bel and the Dragon" : "Bel";
            }
            else if (b.Equals("1maccabees") || b.Equals("1macc") || b.Equals("1mac") || b.Equals("1m") || b.Equals("ima") || b.Equals("1ma") || b.Equals("imac") || b.Equals("imacc") || b.Equals("imaccabees") || b.Equals("1stmaccabees") || b.Equals("firstmaccabees"))
            {
                return "1 Maccabees";
            }
            else if (b.Equals("2maccabees") || b.Equals("2macc") || b.Equals("2mac") || b.Equals("2m") || b.Equals("iima") || b.Equals("2ma") || b.Equals("iimac") || b.Equals("iimacc") || b.Equals("iimaccabees") || b.Equals("2ndmaccabees") || b.Equals("secondmaccabees"))
            {
                return "2 Maccabees";
            }
            else if (b.Equals("1esdras") || b.Equals("1esdr") || b.Equals("1esd") || b.Equals("ies") || b.Equals("1es") || b.Equals("iesd") || b.Equals("iesdr") || b.Equals("iesdras") || b.Equals("1stesdras") || b.Equals("firstesdras"))
            {
                return "1 Esdras";
            }
            else if (b.Equals("prayerofmanasseh") || b.Equals("profman") || b.Equals("prman") || b.Equals("pma") || b.Equals("prayerofmanasses"))
            {
                return "Prayer of Manasseh";
            }
            else if (b.Equals("additionalpsalm") || b.Equals("addpsalm") || b.Equals("addps"))
            {
                return "Additional Psalm";
            }
            else if (b.Equals("3maccabees") || b.Equals("3macc") || b.Equals("3mac") || b.Equals("iiima") || b.Equals("3ma") || b.Equals("iiimac") || b.Equals("iiimacc") || b.Equals("iiimaccabees") || b.Equals("3rdmaccabees") || b.Equals("thirdmaccabees"))
            {
                return "3 Maccabees";
            }
            else if (b.Equals("2esdras") || b.Equals("2esdr") || b.Equals("2esd") || b.Equals("iies") || b.Equals("2es") || b.Equals("iiesd") || b.Equals("iiesdr") || b.Equals("iiesdras") || b.Equals("2ndesdras") || b.Equals("secondesdras"))
            {
                return "2 Esdras";
            }
            else if (b.Equals("4maccabees") || b.Equals("4macc") || b.Equals("4mac") || b.Equals("ivma") || b.Equals("4ma") || b.Equals("ivmac") || b.Equals("ivmacc") || b.Equals("ivmaccabees") || b.Equals("iiiimaccabees") || b.Equals("4thmaccabees") || b.Equals("fourthmaccabees"))
            {
                return "4 Maccabees";
            }
            else if (b.Equals("ode"))
            {
                return "Ode";
            }
            else if (b.Equals("psalmsofsolomon") || b.Equals("pssolomon") || b.Equals("pssol") || b.Equals("psalmssolomon"))
            {
                return "Psalms of Solomon";
            }
            else if (b.Equals("epistletothelaodiceans") || b.Equals("laodiceans") || b.Equals("laod") || b.Equals("eplaod") || b.Equals("epistlaodiceans") || b.Equals("epistlelaodiceans") || b.Equals("epistletolaodiceans"))
            {
                return "Epistle to the Laodiceans";
            }
            else if (b.Equals("matthew") || b.Equals("matt") || b.Equals("mt") || b.Equals("mat"))
            {
                return (fullName) ? "Matthew" : "Mat";
            }
            else if (b.Equals("mark") || b.Equals("mrk") || b.Equals("mk") || b.Equals("mr"))
            {
                return "Mark";
            }
            else if (b.Equals("luke") || b.Equals("luk") || b.Equals("lk") || b.Equals("lu"))
            {
                return "Luke";
            }
            else if (b.Equals("john") || b.Equals("jn") || b.Equals("jhn") || b.Equals("joh"))
            {
                return "John";
            }
            else if (b.Equals("acts") || b.Equals("ac") || b.Equals("act"))
            {
                return "Acts";
            }
            else if (b.Equals("romans") || b.Equals("rom") || b.Equals("ro") || b.Equals("rm"))
            {
                return (fullName) ? "Romans" : "Rom";
            }
            else if (b.Equals("1corinthians") || b.Equals("1cor") || b.Equals("1co") || b.Equals("ico") || b.Equals("icor") || b.Equals("icorinthians") || b.Equals("1stcorinthians") || b.Equals("firstcorinthians"))
            {
                return (fullName) ? "1 Corinthians" : "1Cor";
            }
            else if (b.Equals("2corinthians") || b.Equals("2cor") || b.Equals("2co") || b.Equals("iico") || b.Equals("iicor") || b.Equals("iicorinthians") || b.Equals("2ndcorinthians") || b.Equals("secondcorinthians"))
            {
                return (fullName) ? "2 Corinthians" : "2Cor";
            }
            else if (b.Equals("galatians") || b.Equals("gal") || b.Equals("ga"))
            {
                return (fullName) ? "Galatians" : "Gal";
            }
            else if (b.Equals("ephesians") || b.Equals("ephes") || b.Equals("eph"))
            {
                return (fullName) ? "Ephesians" : "Eph";
            }
            else if (b.Equals("philippians") || b.Equals("phil") || b.Equals("php") || b.Equals("phili"))
            {
                return (fullName) ? "Philippians" : "Php";
            }
            else if (b.Equals("colossians") || b.Equals("col"))
            {
                return (fullName) ? "Colossians" : "Col";
            }
            else if (b.Equals("1thessalonians") || b.Equals("1thess") || b.Equals("1th") || b.Equals("ith") || b.Equals("ithes") || b.Equals("1thes") || b.Equals("ithess") || b.Equals("ithessalonians") || b.Equals("1stthessalonians") || b.Equals("firstthessalonians"))
            {
                return (fullName) ? "1 Thessalonians" : "1Th";
            }
            else if (b.Equals("2thessalonians") || b.Equals("2thess") || b.Equals("2th") || b.Equals("iith") || b.Equals("iithes") || b.Equals("2thes") || b.Equals("iithess") || b.Equals("iithessalonians") || b.Equals("2ndthessalonians") || b.Equals("secondthessalonians"))
            {
                return (fullName) ? "2 Thessalonians" : "2Th";
            }
            else if (b.Equals("1timothy") || b.Equals("1tim") || b.Equals("1ti") || b.Equals("iti") || b.Equals("itim") || b.Equals("itimothy") || b.Equals("1sttimothy") || b.Equals("firsttimothy"))
            {
                return (fullName) ? "1 Timothy" : "1Tim";
            }
            else if (b.Equals("2timothy") || b.Equals("2tim") || b.Equals("2ti") || b.Equals("iiti") || b.Equals("iitim") || b.Equals("iitimothy") || b.Equals("2ndtimothy") || b.Equals("secondtimothy"))
            {
                return (fullName) ? "2 Timothy" : "2Tim";
            }
            else if (b.Equals("titus") || b.Equals("tit"))
            {
                return (fullName) ? "Titus" : "Tit";
            }
            else if (b.Equals("philemon") || b.Equals("philem") || b.Equals("phm"))
            {
                return (fullName) ? "Philemon" : "Phm";
            }
            else if (b.Equals("hebrews") || b.Equals("heb"))
            {
                return (fullName) ? "Hebrews" : "Heb";
            }
            else if (b.Equals("james") || b.Equals("jas") || b.Equals("jm") || b.Equals("jam"))
            {
                return (fullName) ? "James" : "Jam";
            }
            else if (b.Equals("1peter") || b.Equals("1pet") || b.Equals("1pe") || b.Equals("ipe") || b.Equals("ipet") || b.Equals("ipt") || b.Equals("1pt") || b.Equals("ipeter") || b.Equals("1stpeter") || b.Equals("firstpeter"))
            {
                return (fullName) ? "1 Peter" : "1Pet";
            }
            else if (b.Equals("2peter") || b.Equals("2pet") || b.Equals("2pe") || b.Equals("iipe") || b.Equals("iipet") || b.Equals("iipt") || b.Equals("2pt") || b.Equals("iipeter") || b.Equals("2ndpeter") || b.Equals("secondpeter"))
            {
                return (fullName) ? "2 Peter" : "2Pet";
            }
            else if (b.Equals("1john") || b.Equals("1jn") || b.Equals("ijn") || b.Equals("ijo") || b.Equals("1jo") || b.Equals("ijoh") || b.Equals("1joh") || b.Equals("ijhn") || b.Equals("1jhn") || b.Equals("ijohn") || b.Equals("1stjohn") || b.Equals("firstjohn"))
            {
                return (fullName) ? "1 John" : "1Jo";
            }
            else if (b.Equals("2john") || b.Equals("2jn") || b.Equals("iijn") || b.Equals("iijo") || b.Equals("2jo") || b.Equals("iijoh") || b.Equals("2joh") || b.Equals("iijhn") || b.Equals("2jhn") || b.Equals("iijohn") || b.Equals("2ndjohn") || b.Equals("secondjohn"))
            {
                return (fullName) ? "2 John" : "2Jo";
            }
            else if (b.Equals("3john") || b.Equals("3jn") || b.Equals("iiijn") || b.Equals("iiijo") || b.Equals("3jo") || b.Equals("iiijoh") || b.Equals("3joh") || b.Equals("iiijhn") || b.Equals("3jhn") || b.Equals("iiijohn") || b.Equals("3rdjohn") || b.Equals("thirdjohn"))
            {
                return (fullName) ? "3 John" : "3Jo";
            }
            else if (b.Equals("jude") || b.Equals("jud"))
            {
                return "Jude";
            }
            else if (b.Equals("revelation") || b.Equals("rev") || b.Equals("re") || b.Equals("therevelation"))
            {
                return (fullName) ? "Revelation" : "Rev";
            }

			return GetOtherBook(b, fullName);
        }

        /// <summary>
        /// Gets the name of the book for the give string...
        /// </summary>
		/// <param name="book">Book String.</param>
		/// <param name="fullName">True if you want the full name, false if you want the abbrevation.</param>
        /// <returns>Name or Abbreviation of Book</returns>
		public static string GetOtherBook (string book, bool fullName)
		{
			foreach (KeyValuePair<string, string> kvp in frmMain.m_OtherTexts)
			{
				string val = kvp.Key.Replace(" ", "");
				if (book.Equals(val, StringComparison.CurrentCultureIgnoreCase))
					return (fullName) ? kvp.Key : kvp.Value;
			}

			return null;
		}

        /// <summary>
        /// Check to see if the book is from the new testament...
        /// </summary>
        /// <param name="b">Book to look for.</param>
        /// <returns>True if book is in New Testament, otherwise false.</returns>
        public static bool IsBookNewTestament(string b)
        {
            b = b.ToLower();
            if (b.Equals("matthew") || b.Equals("matt") || b.Equals("mt") || b.Equals("mat"))
            {
                return true;
            }
            else if (b.Equals("mark") || b.Equals("mrk") || b.Equals("mk") || b.Equals("mr"))
            {
                return true;
            }
            else if (b.Equals("luke") || b.Equals("luk") || b.Equals("lk"))
            {
                return true;
            }
            else if (b.Equals("john") || b.Equals("jn") || b.Equals("jhn") || b.Equals("joh"))
            {
                return true;
            }
            else if (b.Equals("acts") || b.Equals("ac") || b.Equals("act"))
            {
                return true;
            }
            else if (b.Equals("romans") || b.Equals("rom") || b.Equals("ro") || b.Equals("rm"))
            {
                return true;
            }
            else if (b.Equals("1corinthians") || b.Equals("1cor") || b.Equals("1co") || b.Equals("ico") || b.Equals("icor") || b.Equals("icorinthians") || b.Equals("1stcorinthians") || b.Equals("firstcorinthians"))
            {
                return true;
            }
            else if (b.Equals("2corinthians") || b.Equals("2cor") || b.Equals("2co") || b.Equals("iico") || b.Equals("iicor") || b.Equals("iicorinthians") || b.Equals("2ndcorinthians") || b.Equals("secondcorinthians"))
            {
                return true;
            }
            else if (b.Equals("galatians") || b.Equals("gal") || b.Equals("ga"))
            {
                return true;
            }
            else if (b.Equals("ephesians") || b.Equals("ephes") || b.Equals("eph"))
            {
                return true;
            }
            else if (b.Equals("philippians") || b.Equals("phil") || b.Equals("php") || b.Equals("phili"))
            {
                return true;
            }
            else if (b.Equals("colossians") || b.Equals("col"))
            {
                return true;
            }
            else if (b.Equals("1thessalonians") || b.Equals("1thess") || b.Equals("1th") || b.Equals("ith") || b.Equals("ithes") || b.Equals("1thes") || b.Equals("ithess") || b.Equals("ithessalonians") || b.Equals("1stthessalonians") || b.Equals("firstthessalonians"))
            {
                return true;
            }
            else if (b.Equals("2thessalonians") || b.Equals("2thess") || b.Equals("2th") || b.Equals("iith") || b.Equals("iithes") || b.Equals("2thes") || b.Equals("iithess") || b.Equals("iithessalonians") || b.Equals("2ndthessalonians") || b.Equals("secondthessalonians"))
            {
                return true;
            }
            else if (b.Equals("1timothy") || b.Equals("1tim") || b.Equals("1ti") || b.Equals("iti") || b.Equals("itim") || b.Equals("itimothy") || b.Equals("1sttimothy") || b.Equals("firsttimothy"))
            {
                return true;
            }
            else if (b.Equals("2timothy") || b.Equals("2tim") || b.Equals("2ti") || b.Equals("iiti") || b.Equals("iitim") || b.Equals("iitimothy") || b.Equals("2ndtimothy") || b.Equals("secondtimothy"))
            {
                return true;
            }
            else if (b.Equals("titus") || b.Equals("tit"))
            {
                return true;
            }
            else if (b.Equals("philemon") || b.Equals("philem") || b.Equals("phm"))
            {
                return true;
            }
            else if (b.Equals("hebrews") || b.Equals("heb"))
            {
                return true;
            }
            else if (b.Equals("james") || b.Equals("jas") || b.Equals("jm") || b.Equals("jam"))
            {
                return true;
            }
            else if (b.Equals("1peter") || b.Equals("1pet") || b.Equals("1pe") || b.Equals("ipe") || b.Equals("ipet") || b.Equals("ipt") || b.Equals("1pt") || b.Equals("ipeter") || b.Equals("1stpeter") || b.Equals("firstpeter"))
            {
                return true;
            }
            else if (b.Equals("2peter") || b.Equals("2pet") || b.Equals("2pe") || b.Equals("iipe") || b.Equals("iipet") || b.Equals("iipt") || b.Equals("2pt") || b.Equals("iipeter") || b.Equals("2ndpeter") || b.Equals("secondpeter"))
            {
                return true;
            }
            else if (b.Equals("1john") || b.Equals("1jn") || b.Equals("ijn") || b.Equals("ijo") || b.Equals("1jo") || b.Equals("ijoh") || b.Equals("1joh") || b.Equals("ijhn") || b.Equals("1jhn") || b.Equals("ijohn") || b.Equals("1stjohn") || b.Equals("firstjohn"))
            {
                return true;
            }
            else if (b.Equals("2john") || b.Equals("2jn") || b.Equals("iijn") || b.Equals("iijo") || b.Equals("2jo") || b.Equals("iijoh") || b.Equals("2joh") || b.Equals("iijhn") || b.Equals("2jhn") || b.Equals("iijohn") || b.Equals("2ndjohn") || b.Equals("secondjohn"))
            {
                return true;
            }
            else if (b.Equals("3john") || b.Equals("3jn") || b.Equals("iiijn") || b.Equals("iiijo") || b.Equals("3jo") || b.Equals("iiijoh") || b.Equals("3joh") || b.Equals("iiijhn") || b.Equals("3jhn") || b.Equals("iiijohn") || b.Equals("3rdjohn") || b.Equals("thirdjohn"))
            {
                return true;
            }
            else if (b.Equals("jude") || b.Equals("jud"))
            {
                return true;
            }
            else if (b.Equals("revelation") || b.Equals("rev") || b.Equals("re") || b.Equals("therevelation"))
            {
                return true;
            }

            return false;
        }
    }
}
